<?php

class RangeGenerator {
	
	/**
	 * Create a number range in an array.
	 *
	 * @param int $start
	 * @param int $end
	 * @return array
	 */
	public static function range ($start, $end) {
		if ($start >= $end)
		  return array();
		$end++;
		$res = array();
		for ($i = $start; $i < $end; $i++) {
			$res[] = $i;
		}
        print $start.":".$end;
        var_dump($res);
		return $res;
	}
	
	/**
	 * Create a number range in an array. The numbers are prepended with zeros.
	 *
	 * @param int $start   First number of range
	 * @param int $end     Last number of range
	 * @param int $length  Length to which the numbers are prepended with zeros.
	 * @return array
	 */
	public static function rangeLZ ($start, $end, $length) {
        if ($start >= $end)
          return array();
        $end++;
        $res = array();
        for ($i = $start; $i < $end; $i++) {
        	$str = $i . "";
        	if (strlen($str) < $length)
        	   $str = self::addLeadingZeros($str, $length);
            $res[] = $str;
        }
        return $res;
	}
	
	/**
	 * Prepend the value with zeros to fit the given length.
	 *
	 * @param mixed $val
	 * @param int $length
	 */
	public static function addLeadingZeros ($val, $length) {
		while (strlen($val) < $length) {
			$val = "0" . $val;
		}
		return $val;
	}
	
}

?>